1 import javax.swing.*;
2 import java.awt.*;
3 import java.awt.
event.*;
4
5 class
ViewFrame extends JFrame
6 {
7     Container c;
8     TextArea ta;
9     
10     JButton btnBack;
11     JPanel p1,p2;
12
13     ViewFrame()
14     {
15         c =getContentPane();
16         c.setLayout(
new BoxLayout(c , BoxLayout.Y_AXIS));
17
18         p1 =
new JPanel();
19         ta =
new TextArea(5,40);
20         ta.setBackground(Color.orange);
21         p1.
add(ta);
22         c.
add(p1);
23
24         p2 =
new JPanel();
25         btnBack =
new JButton("Back");
26         btnBack.setBackground(Color.orange);
27         p2.
add(btnBack);
28         c.
add(p2);
29     
30         DbHandler db =
new DbHandler();
31         String data = db.viewStudent();
32         ta.setText(data);
33     
34         btnBack.addActionListener(
new ActionListener(){
35             
public void actionPerformed(ActionEvent ae){
36                 MainFrame a =
new MainFrame();
37                 dispose();
38             }});
39     
40
41
42         setTitle(
"View Student");
43         setSize(
500,400);
44         setLocationRelativeTo(
null);
45         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
46         setVisible(
true);
47         }
48 }
// end of class Addframe


Gõ tìm kiếm nhanh...